
#include "lnBinTree.h"

int main ()
{
    PLNBinTree t, newTree, ct;
    PBinTreeNode p, q;
    ELEMTYPE x;

    t = createEmptyBinTree();
    
    addChildBinTree(&t, NULL, 'A', 1);
    addChildBinTree(&t, t, 'B', 1);
    addChildBinTree(&t, t, 'C', 0);

    /*
    x = 'B';

    p = locateChildBinTree(t, x);
    if (p != NULL)
    {
        addChildBinTree(&t, p, 'D', 1);
        addChildBinTree(&t, p, 'E', 0);
    }

    x = 'D';

    p = locateChildBinTree(t, x);
    if (p != NULL)
    {
        addChildBinTree(&t, p, 'G', 1);
    }

    x = 'D';

    p = locateChildBinTree(t, x);
    if (p != NULL)
    {
        addChildBinTree(&t, p, 'H', 0);
    }
    */
    print(t);

	printf("Total leafs :%d\n", leaf(t));

    destroyBinTree(t);
/*
    addChildBinTree(&t, t, 'X', 1);
    print(t);
    
    
    if (p != NULL)
    {
        printf("Node with info as %c is found!!\n", x);
        printf("Node ADDRESS is %u!!\n\n", p);
    }
    else
    {
        printf("Node with info as %c is not found!!\n\n", x);
    }

    print(t);

    addChildBinTree(&t, p, 'D', 0);

    print(t);
    
    q = parent(t, p);
    
    if (q != NULL)
    {
        printf("Node %c's parent is found!!\n", p->info);
        printf("Node ADDRESS is %u!!\n", p);
        printf("PARENT ADDRESS is %u!!\n\n", q);
    }
    else
    {
        printf("Node %c's not found!!\n\n", p->info);
    }
    
    newTree = duplicateBinTree(t);
    
    if (newTree != NULL)
    {
        printf("DUPLICATED a NEW BINARY TREE\n");
        print(newTree);
        x = 'B';
        p = locateChildBinTree(newTree, x);
        addChildBinTree(&newTree, p, 'Z', 1);
        printf("\nTHE ORIGINAL BINARY TREE\n");
        print(t);
        print(newTree);
        
        x = 'C';
        p = locateChildBinTree(newTree, x);
        addChildBinTree(&newTree, p, 'E', 1);
        addChildBinTree(&newTree, p, 'F', 0);
        print(newTree);
        x = 'A';
        p = locateChildBinTree(newTree, x);
        deleteChildBinTree(newTree, p, 0);
        print(newTree);
        
        destroyBinTree(newTree);
        printf("Printing a destroied Binary Tree\n\n");
        //print(newTree);
        destroyBinTree(t);
    }

    
    
    ct = createEmptyBinTree();
    
    addChildBinTree(&ct, NULL, '9', 1);

    printf("USING constructBinTree to construct a new tree!\n\n");
    ct = constructBinTree(ct, t, newTree);
    print(ct);
    destroyBinTree(ct);
*/

    return 0;
}
